package com.bigger.controller;

import com.bigger.dto.OrderPageDTO;
import com.bigger.dto.UpdateOrderDTO;
import com.bigger.result.PageResult;
import com.bigger.result.Result;
import com.bigger.service.OrderService;
import com.bigger.vo.OrderDetailVO;
import com.bigger.vo.OrderVO;
import com.bigger.vo.TurnoverVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/order")
public class OrderController {
    @Autowired
    private OrderService orderService;
    @GetMapping("/get")
    public Result<PageResult<OrderVO>> page(OrderPageDTO orderPageDTO){
        PageResult<OrderVO> pageResult=orderService.page(orderPageDTO);
        return Result.success(pageResult);
    }
    @PutMapping("/update")
    public Result<String> update(@RequestBody UpdateOrderDTO updateOrderDTO){
        orderService.update(updateOrderDTO);
        return Result.success("更新成功");
    }
    @GetMapping("/get/{id}")
    public Result<OrderDetailVO> getById(@PathVariable("id") Long id){
        OrderDetailVO orderDetailVO=orderService.getById(id);
        return Result.success(orderDetailVO);
    }
    @GetMapping("/get/turnover")
    public Result<TurnoverVO> getTurnover(){
        TurnoverVO turnoverVO=orderService.getTurnover();
        return Result.success(turnoverVO);
    }
}
